//
//  WKDoubiListViewController.m
//  WKMaybell
//
//  Created by 何文虎 on 2019/1/3.
//  Copyright © 2019 何文虎. All rights reserved.
//

#import "WKDoubiListViewController.h"
#import "WKDoubiHeaderView.h"
#import "WKDoubiListCell.h"

@interface WKDoubiListViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    WKDoubiHeaderView *_headerView;
}
@property(nonatomic,strong)UITableView *tableView;
@end

@implementation WKDoubiListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViews];
}

- (void)initViews{
  
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.naviBar configMynavibarStyle:SSNavigationBarWhiteStyle];
    self.naviBar.backgroundColor = [UIColor clearColor];
    [self.naviBar hiddenNaviBarLine];
    self.naviBar.title = @"我的痘币";
    
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    
    _headerView = [[WKDoubiHeaderView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, NavBarHeight+123+63+12)];
    _tableView.tableHeaderView = _headerView;
    
    [_tableView registerClass:[WKDoubiListCell class] forCellReuseIdentifier:NSStringFromClass([WKDoubiListCell class])];
    
    if (@available(iOS 11.0, *)) {
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else{
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    WKDoubiListCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([WKDoubiListCell class]) forIndexPath:indexPath];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 107+24;
}

- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
    UIView *lineview = [[UIView alloc]initWithFrame:CGRectMake(12, 17, 3, 10)];
    lineview.backgroundColor = BACK_COLOR;
    lineview.layer.cornerRadius = 1.5;
    lineview.layer.masksToBounds = YES;
    [headerView addSubview:lineview];
    UILabel *titleLb = [[UILabel alloc]initWithFrame:CGRectMake(26, 12, 150, 20)];
    titleLb.text = @"新手任务";
    titleLb.font = PFSC_BoldFont(15);
    titleLb.textColor = UIColorFromHex(0x3C3C3C);
    [headerView addSubview:titleLb];
    
    return headerView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 44;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
